﻿@{
	ViewBag.Title = @Resources.InvoiceManage;
}
<table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
	<tr>
		<td class="b1">
			<div>
				<p><img src="~/images/icon_06.png" align="absmiddle" />&nbsp;@Resources.Menu_UserCenter<span>&nbsp;>>&nbsp;</span>@Resources.InvoiceManage
			</div>
		</td>
	</tr>
	<tr>
		<td class="b4">
			<div class="c">
				<div class="right" id="mainFrame">
					<div class="right_cont">
						<div id="dataGrid"></div>
					</div>
				</div>
			</div>
		</td>
	</tr>
</table>
<div id="invoiceWindow" class="easyui-window"
	title="@Resources.CheckAttendConferenceInfo" data-options="closed:true,minimizable:false,iconCls:'icon-save'"
	style="width:1200px; display:none;">
	<div class="main">
		<div class="box clearfix">
			<h3 id="invoiceWindowTitle" class="tit01"></h3>
			<form id="invoiceDetail" method="post">
				@Html.AntiForgeryToken()
				<table width="100%" height="100%" id="invoicetblDetail" cellpadding="0" cellspacing="1" border="0" class="tastyle01">
					<tr>
						<td style="text-align: right;" class="w1 c1">@Resources.InvoiceTitle：</td>
						<td style="text-align: left;" class="w2 c2">
							<input id="invoiceTitle" name="invoiceTitle" class="easyui-textbox" style="height:27px; width:300px;" />
							<input type="hidden" id="cid" name="cid" />
						</td>
						<td style="text-align: right;" class="w1 c1">@Resources.TaxNum：</td>
						<td style="text-align: left;" class="w2 c2">
							<input id="taxNum" name="taxNum" class="easyui-textbox" style="height:27px; width:300px;" />
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c3">@Resources.AddressAndTel：</td>
						<td style="text-align: left;" class="w2 c4">
							<input id="addressAndTel" name="addressAndTel" class="easyui-textbox" style="height:27px; width:300px;" />
						</td>
						<td style="text-align: right;" class="w1 c3">@Resources.Bank：</td>
						<td style="text-align: left;" class="w2 c4">
							<input id="bank" name="bank" class="easyui-textbox" style="height:27px; width:300px;" />
						</td>
					</tr>
					<tr>
						<td style="text-align: right;" class="w1 c1">@Resources.BankAccount：</td>
						<td style="text-align: left;" class="w2 c2">
							<input id="bankAccount" name="bankAccount" class="easyui-textbox" style="height:27px; width:300px;" />
						</td>
						<td style="text-align: right;" class="w1 c1">@Resources.InvoiceId：</td>
						<td style="text-align: left;" class="w2 c2">
							<input id="invoiceId" name="invoiceId" class="easyui-combobox" style="height:27px; width:300px;" />
						</td>
					</tr>
				</table>
			</form>
			<div class="btnDiv">
				<input type="button" class="gbtn" onclick="saveData();" value="@Resources.Submit" />&nbsp;&nbsp;
				<input type="button" class="rbtn" onclick="$('#invoiceWindow').window('close');" value="@Resources.Cancel" />
			</div>
		</div>
	</div>
</div>

@section Scripts {
<script>
	var windowHeight = $(window).height() - 200;
	$("#mainFrame").css("height", (windowHeight)+"px");

	$(function () {
		$("#dataGrid").datagrid({
			url: "@Url.Action(nameof(ProfileInvoiceController.GetData), nameof(ProfileInvoiceController).GetControllerName())",
			method: "get",
			singleSelect: true,
			width: 1200,
			height: $(window).height() - 110,
			nowrap: false,
			pagination: true,
			pageSize: @ConstValues.DefaultGridRows,
			striped: true,
			pageSize: 100,
			pageList: [100, 200, 300, 400, 500],
			frozenColumns: [[
				{
					field: "Operate", title: "@Resources.Operate", align: "center", width: 150,
					formatter: function (value, rec) {
			    			var strInfo = "<a href='#' style='color:#66CDAA;font-weight:bold;text-decoration:underline;' onclick='editData(\""
							+ rec.id + "\",\""+ rec.conferenceId + "\")'>@Resources.Modify</a> ";
			    			return strInfo;
					}
				},
				{
					field: "conferenceName", title: "@Resources.ConferenceName", sortable: true, align: "center", width: 300,
			    		formatter: function (value, rec) {
			    			var conStr = ""
			    			if (rec.homePageUrl != null && rec.homePageUrl != "") {
			    				conStr += "<a href=' "+ rec.homePageUrl +" ' style='color:#1874CD;text-decoration:underline;' target='_blank'>" + value + "</a>  "
			    			} else {
			    				var tmp = rec.conferenceNickName == null ? "" : rec.conferenceNickName.replace(new RegExp("'",'g'),"’").replace(new RegExp('"','g'),"“");
			    				conStr += "<a href='@Url.Action(nameof(MeetingMainController.Index), nameof(MeetingMainController).GetControllerName())"
									+ "/" + tmp + "' style='color:#1874CD;text-decoration:underline;' target='_blank'>" + value + "</a>  ";
			    			}
			    			return conStr;
			    		}
				}
			]],
			columns: [[
			    { field: "fullName", title: "@Resources.FullName", align: "center", sortable: true, width: 200 },
			    { field: "invoiceTitle", title: "@Resources.InvoiceTitle", align: "center", sortable: true, width: 300 },
			    { field: "taxNum", title: "@Resources.TaxNum", align: "center", sortable: true, width: 200 },
			    { field: "addressAndTel", title: "@Resources.AddressAndTel", align: "center", sortable: true, width: 300 },
			    { field: "bank", title: "@Resources.Bank", align: "center", sortable: true, width: 250 },
			    { field: "bankAccount", title: "@Resources.BankAccount", align: "center", sortable: true, width: 200 },
			    { field: "invoiceId", title: "@Resources.InvoiceId", align: "center", sortable: true, width: 150 }
			]]
		});
		$("#invoiceWindow").window({
			onOpen: function () {
				$(this).scrollTop(0);
			},
			top: ($(window).height() - 600) * 0.5
		});
	});
	function editData(id,conferenceId) {
		var url = "@Url.Action(nameof(ProfileInvoiceController.GetInvoiceInfoData),
				nameof(ProfileInvoiceController).GetControllerName())" + "/" + id;
		$.get(url, null, function (data, textStatus, jqXHR) {
			if (data.result == "@ConstValues.AjaxFailResult") {
				common.showError("@Resources.NullData");
			} else {
				$("#cid").val(data.data.id);
				$("#invoiceTitle").textbox("setValue", data.data.invoiceTitle);
				$("#taxNum").textbox("setValue", data.data.taxNum);
				$("#addressAndTel").textbox("setValue", data.data.addressAndTel);
				$("#bank").textbox("setValue", data.data.bank);
				$("#bankAccount").textbox("setValue", data.data.bankAccount);
				$("#invoiceId").combobox({
					url: "@Url.Action(nameof(UtilityController.GetInvoiceTitle), nameof(UtilityController).GetControllerName())"+"?conferenceId="+conferenceId,
					valueField: "id",
					textField: "name",
					required: true,
					editable: false,
					panelHeight: "auto",
				});
				$("#invoiceId").combobox("setValue", data.data.invoiceId);
				$("#invoiceWindowTitle").text("@Resources.ModifyInvoiceInfo");
				$("#invoiceWindow").window("open");
			};
		});
	}

	function saveData() {
		$.messager.confirm("@Resources.Submit", "@Resources.CfmSave", function (r) {
			if (r) {
				var loading = layer.load(0,  {
					shade: [0.4,"#fff"]
				});

				$("#invoiceDetail").form({
					iframe: false,
					success: function (data) { }
				});

				$("#invoiceDetail").form("submit", {
					url: "@Url.Action(nameof(ProfileInvoiceController.Modify), nameof(ProfileInvoiceController).GetControllerName())",
					onSubmit: function (param) {
						param.random = Math.random();
					},
					success: function (data) {
						layer.close(loading);
						data = JSON.parse(data);
						if (data.result == "@ConstValues.AjaxFailResult") {
							common.showError(data.message);
						} else {
							common.showSuccess(data.message, true);
							$("#invoiceWindow").window("close");
							$("#dataGrid").datagrid("reload");
						}
					},
				});
			}
		});
	}
</script>
}